home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
qbpacket.zip
/
LOAN2.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-10-05
|
3KB
|
117 lines
REM LOAN PROGRAM, PART II (LOAN2.BAS)
' This program calculates and prints the
' loan schedule. It's a modified and updated
' version.
' Initialization section
CLS
PRINT "LOAN AMORTIZATION"
PRINT
' Input section
INPUT "Enter the amount of the loan", A
INPUT "Enter the yearly interest rate (in %)", Rate
INPUT "Input the number of years of the loan", Years
' Change annual interest rate to monthly rate
I = Rate / 12 / 100
' Convert years to number of monthly payments
N = Years * 12
' Compute the monthly payment
P = I * A * (((1 + I) ^ N) / (((1 + I) ^ N) - 1))
' Initialize variables for the amortization schedule
Ba1 = A
Totint = 0
Image$ = "$$#########,.##"
' Printing the menu of choices
PRINT : PRINT "MENU"
PRINT
PRINT "1 - Display payment data"
PRINT "2 - Display amortization schedule"
PRINT "3 - Print payment data and amortization schedule"
PRINT "Any other number to exit"
PRINT
INPUT "Enter your choice ", Choice
SELECT CASE Choice
CASE 1
PRINT "The monthly payment for a loan of $"; A
PRINT "at a rate of"; Rate; "%"
PRINT "for"; Years; "years ";
PRINT "is";
PRINT USING Image$; P
CASE 2
' Display the amortization schedule
PRINT "NUM";
PRINT TAB(13); "INTEREST";
PRINT TAB(27); "PRINCIPAL";
PRINT TAB(44); "PRIN BAL";
PRINT TAB(62); "TOT INT"
' Do the loop for the number of payments
FOR J = 1 TO N
' Compute the interest
Interest = Ba1 * I
' Compute the principal
Principal = P - Interest
' Force out the last payment
IF J = N THEN Principal = Ba1
' Update the loan balance
Ba1 = Ba1 - Principal
' Update the total interest
Totint = Totint + Interest
' Display the monthly payment detail
PRINT J;
PRINT USING Image$; TAB(6); Interest;
PRINT USING Image$; TAB(21); Principal;
PRINT USING Image$; TAB(37); Ba1;
PRINT USING Image$; TAB(54); Totint
NEXT J
CASE 3
' Print payment data on printer
LPRINT "NUM";
LPRINT TAB(13); "INTEREST";
LPRINT TAB(27); "PRINCIPAL";
LPRINT TAB(44); "PRIN BAL";
LPRINT TAB(62); "TOT INT"
' Do the loop for the number of payments
DO WHILE J <= N
' Compute the interest
Interest = Ba1 * I
' Compute the principal
Principal = P - Interest
' Force out the last payment
IF J = N THEN Principal = Ba1
' Update the loan balance
Ba1 = Ba1 - Principal
' Update the total interest
Totint = Totint + Interest
' Display the monthly payment detail
LPRINT J;
LPRINT USING Image$; TAB(6); Interest;
LPRINT USING Image$; TAB(21); Principal;
LPRINT USING Image$; TAB(37); Ba1;
LPRINT USING Image$; TAB(54); Totint
J = J + 1
LOOP
CASE ELSE
PRINT "Goodbye for now!"
END
END SELECT